package com.df.tv.launcher.view;

import android.content.Context;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.df.tv.launcher.R;

import com.telecom.tv189.comlib.util.SystemProperties;

/**
 * 设备号
 * 
 * @author John
 */
public class HomeEquipmentInformationView extends FrameLayout {
    public static final String PROP_KEY_SN = "android.os.build.serial";
    private TextView equipment_text;

    public HomeEquipmentInformationView(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
        initView(context);
    }

    public HomeEquipmentInformationView(Context context, AttributeSet attrs) {
        super(context, attrs);
        initView(context);
    }

    public HomeEquipmentInformationView(Context context) {
        super(context);
        initView(context);
    }

    private void initView(Context context) {
        LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        LinearLayout linearView = (LinearLayout) inflater.inflate(R.layout.equipmentinformationview, null);
        equipment_text = (TextView) linearView.findViewById(R.id.equipment_text);
        String device_number = SystemProperties.get(PROP_KEY_SN, null);
        if (!TextUtils.isEmpty(device_number) && device_number.length() >= 24) {
            String sub_one = device_number.substring(12, 16);
            String sub_two = device_number.substring(18, device_number.length());
            equipment_text.setText(sub_one + "" + sub_two);
        }
        addView(linearView);
    }
}
